package com.example.supermarket.controller;

import com.example.supermarket.pojo.Result;
import com.example.supermarket.pojo.Shop;
import com.example.supermarket.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/shop")
public class ShopController {

    @Autowired
    private ShopService shopService;

    @GetMapping("/getAllShop")
    public Result<List<Shop>> getAllShop(){
        List<Shop> list=shopService.getAllShop();
        return Result.success(list);
    }

    @GetMapping("/getShopByBusinessId")
    public Result<List<Shop>> getShopByBusinessId(){
        List<Shop> list=shopService.getShopByBusinessId();
        return Result.success(list);
    }

    @GetMapping("/getItemByShopId")
    public Result<List<Integer>> getItemByShopId(@RequestParam Integer shopId){
        List<Integer> list=shopService.getItemByShopId(shopId);
        return Result.success(list);
    }

    @GetMapping("getByShopId")
    public Result<Shop> getByShopId(Integer shopId){
        Shop shop=shopService.getByShopId(shopId);
        return Result.success(shop);
    }
}
